﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameServer.Networking.Packets
{
    class PACKET_COUPON_BUY : Packet
    {
        public enum ErrorCode
        {
            NotEnoughCoupons = 1
        }
        public PACKET_COUPON_BUY(ErrorCode ErrCode)
        {
            newPacket(25606);
            addBlock((int)ErrCode);
        }
        public PACKET_COUPON_BUY(string WeaponCode, Virtual_Objects.User.virtualUser User)
        {
            int ItemCount = 0;
            newPacket(25606);
            addBlock(0);
            addBlock(User.getSlots()); // Slot Enabled
            string Items = string.Empty;
            StringBuilder WeaponList = new StringBuilder();
            for (int I = 0; I < 30; I++)
            {
                if (User.Inventory[I] != null)
                {
                    InventoryItem _Inv = User.Inventory[I];
                    TimeSpan ExpireTime = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(_Inv._StartTime);

                    WeaponList.Append(_Inv._Code.ToUpper() + "-3-0-" + _Inv._StartTime + "-0-0-0-0-0-9999-9999,");/*+ ExpireTime.TotalSeconds +*/
                    ItemCount++;
                }
            }
            for (int i = 0; i < (31 - ItemCount); i++)
            {
                Items += "^,";
            }
            addBlock(Items);
            addBlock(User.Dinar);
            addBlock(0);
            addBlock(User.Coupons);
        }
    }
}
